﻿Chenxin.UI.AchievementStat = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/AchievementStat.ashx',
    createSearch: function() {
        return new Chenxin.UI.AchievementStatSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.GroupReportGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            id: 'search_table',
            renderTo: 'search_table',
            hasCheckBox: false,
            modelId: 'departid',
            autoLoad: false,
            cellBorder: true,
            sortType: 'local',
            scope: this,
            height: 400,
            rowGroupSetting: [
				{ field: 'business', head: '商圈', width: 120, autoCount: true },
				{ field: 'departname', head: '门店', width: 120, autoCount: true }
			],
            columns: {
                a: {
                    head: '买卖',
                    items: {
                        a_count: {
                            head: '业绩',
                            width: 120,
                            sortable: true
                        },
                        a_sum: {
                            head: '合同数',
                            width: 80,
                            sortable: true
                        },
                        a_point: {
                            head: '点数',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                b: {
                    head: '租赁',
                    items: {
                        b_count: {
                            head: '业绩',
                            width: 120,
                            sortable: true
                        },
                        b_sum: {
                            head: '合同数',
                            width: 80,
                            sortable: true
                        },
                        b_point: {
                            head: '点数',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                totil: {
                    head: '业绩小计',
                    width: 120,
                    sortable: true
                },
                c: {
                    head: '零散业务',
                    items: {
                        c_count: {
                            head: '业绩',
                            width: 120,
                            sortable: true
                        },
                        c_sum: {
                            head: '合同数',
                            width: 80,
                            sortable: true
                        },
                        c_point: {
                            head: '点数',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                d: {
                    head: '其他业务',
                    items: {
                        d_count: {
                            head: '业绩',
                            width: 120,
                            sortable: true
                        },
                        d_sum: {
                            head: '合同数',
                            width: 80,
                            sortable: true
                        },
                        d_point: {
                            head: '点数',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                e: {
                    head: '联动业务',
                    items: {
                        e_count: {
                            head: '业绩',
                            width: 120,
                            sortable: true
                        },
                        e_sum: {
                            head: '合同数',
                            width: 80,
                            sortable: true
                        },
                        e_point: {
                            head: '点数',
                            width: 80,
                            sortable: true
                        }
                    }
                },
                all_totil: {
                    head: '业绩合计',
                    width: 120,
                    sortable: true
                }
            }
        });
    },
    initEvent: function() {
        var _this = this;

    },
    initComponent: function() {
        Chenxin.UI.AchievementStat.superclass.initComponent.call(this);
    }
});

/**
*查询面板
*/
Chenxin.UI.AchievementStatSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'search',
    initEvent: function() {
        var _this = this;

        //查询按钮
        $('#btn_search').click(function() {
            _this.scope.reloadGrid();
        });

        var curdate = new Date();
        $('#starttime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 1) + '-1');
        if (curdate.getMonth() + 1 == 12)
            $('#eTime').val(curdate.getFullYear() + 1 + '-1-1');
        else
            $('#eTime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 2) + '-1');
//        /*************************事件：起始日期得到焦点************************/
//        $("#DateFr").focus(function() {
//            WdatePicker({ dateFmt: 'yyyy-MM-dd', oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
//        });
//        /*************************事件：终止日期得到焦点************************/
//        $("#DateTo").focus(function() {
//            WdatePicker({ dateFmt: 'yyyy-MM-dd', oncleared: function() { $(this).blur(); }, onpicked: function() { $(this).blur(); } })
//        });
    },
    createComboList: function() {
        var combl = new Chenxin.UI.StructComboList({
            tbxWidth: 65
        });
        var structs = combl.comboList;
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.AchievementStatSearch.superclass.initComponent.call(this);
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var AchievementStat = new Chenxin.UI.AchievementStat();
});